package org.springcloud.wisdom.spring_02_classroom.teacher.tschedule.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springcloud.wisdom.spring_02_classroom.admin.createcourse.entity.Course;
import org.springcloud.wisdom.spring_02_classroom.student.sschedule.entity.Student;


import java.util.List;

@Mapper
public interface TeacherScheduleDao{
    //教师查看自己名下的课程
    @Select("SELECT * " +
            "FROM course " +
            "where tid = #{tid} AND isdel=0")
    List<Course> selectCoursesByTid(@Param("tid") String tid );

    //教师查看所属课程的学生
    @Select("SELECT s.sid AS sid, s.sname AS sname, s.gender AS gender, " +
            "d.deptname AS deptname " +
            "FROM student s " +
            "INNER JOIN department d ON s.dept = d.deptid " +
            "INNER JOIN choose c ON s.sid = c.sid " +
            "WHERE c.tid = #{tid} "+
            "AND c.cid= #{cid}"+
            "ORDER BY d.deptid")
    List<Student> selectCourseStudent(@Param("tid") String tid, @Param("cid") String cid);

    // 新增方法，根据课程ID获取课时数
    @Select("SELECT chour FROM course WHERE cid = #{cid}")
    String selectChourByCid(@Param("cid") String cid);

    //往年课程
    @Select("<script>" +
            "SELECT * " +
            "FROM course " +
            "<where>" +
            "   tid = #{tid} AND isdel=1 " +
            "</where>" +
            "LIMIT #{start}, #{size} "+
            "</script>")
    public List<Course> getcoursehistory(int start, int size, String tid );

    @Select("<script>" +
            "SELECT count(*) FROM course " +
            "<where>" +
            " tid = #{tid} AND isdel=1 " +
            "</where>" +
            "</script>")
    public int Countcoursehistory(  String tid  );

}
